package cn.jtfadmin.core.modules.sys.domain.dto;

import cn.jtfadmin.base.lang.enums.BooleanEnum;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 用户具有的菜单和权限树
 *
 * @author akfh
 * @since 1.0
 */
@Data
public class UserMenuRDTO implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    /**
     * 用户的具有的菜单
     */
    protected List<MenuModelRDTO> menu;

    /**
     * 用户具有的按钮权限
     */
    protected List<AuthMenuRDTO> auth;

    @Data
    public static class AuthMenuRDTO implements Serializable {

        protected String id;

        /**
         * 权限标示
         */
        protected String action;

        /**
         * 权限描述
         */
        protected String describe;


        public AuthMenuRDTO() {

        }


        public AuthMenuRDTO(String action, String describe) {
            setAction(action);
            setDescribe(describe);

        }

        public AuthMenuRDTO(String id, String action, String describe) {
            this.id = id;
            this.action = action;
            this.describe = describe;
        }
    }

    @Data
    public static class MenuModelRDTO implements Serializable {

        /**
         *
         */
        private static final long serialVersionUID = 1L;

        /**
         * 菜单id
         */
        protected String id;

        /**
         * 是否生成路由 1 是,0 否
         */
        protected BooleanEnum routeFlag;

        /**
         * 路由path
         */
        protected String path;

        /**
         * 路由名称/菜单名称
         */
        protected String name;

        /**
         * 是否隐藏路由，默认都是显示的
         */
        protected BooleanEnum hidden;


        /**
         * 菜单源数据
         */
        protected MetaRDTO meta;

        /**
         * 组件 名称
         */
        protected String component;

        /**
         * 一级菜单跳转地址
         */
        protected String redirect;

        /**
         * 子菜单
         */
        protected List<MenuModelRDTO> children;


    }

    /**
     * 菜单源数据
     */
    @Data
    public static class MetaRDTO implements Serializable {
        public MetaRDTO() {
        }

        public MetaRDTO(Boolean keepAlive, String title, String icon, String url) {
            this.keepAlive = keepAlive;
            this.title = title;
            this.icon = icon;
            this.url = url;
        }

        /**
         * 由用户设置是否缓存页面 用布尔值
         */
        protected Boolean keepAlive;

        /**
         * 菜单名称
         */
        protected String title;


        /**
         * 菜单图标
         */
        protected String icon;

        /**
         * 菜单url
         */
        protected String url;

    }
}
